package com.bcdat.bcdatbrace.utils;


import com.bcdat.bcdatbrace.utils.enums.ResultEnums;
import com.bcdat.bcdatbrace.utils.vo.ResultVO;

/**
 * @Description: 将结果转换为封装后的对象
 * @author lsy
 * @date 2019-5-10
 */
public class ResultVOUtil {

   public static <T> ResultVO<T> success() {
      return new ResultVO<T>().setCode(ResultEnums.SUCCESS).setMsg(ResultEnums.SUCCESS.getMessage());
   }

   public static <T> ResultVO<T> success(String message) {
      return new ResultVO<T>().setCode(ResultEnums.SUCCESS).setMsg(message);
   }

   public static <T> ResultVO<T> success(Integer code, String message) {
      return new ResultVO<T>().setCode(code).setMsg(message);
   }

   public static <T> ResultVO<T> success(Integer code, String message, T data) {
      return new ResultVO<T>().setCode(code).setMsg(message).setData(data);
   }

   public static <T> ResultVO<T> success(T data) {
      return new ResultVO<T>().setCode(ResultEnums.SUCCESS).setMsg(ResultEnums.SUCCESS.getMessage()).setData(data);
   }

   public static <T> ResultVO<T> error() {
      return new ResultVO<T>().setCode(ResultEnums.ERROR).setMsg(ResultEnums.ERROR.getMessage());
   }

   public static <T> ResultVO<T> error(Integer code, String message) {
      return new ResultVO<T>().setCode(code).setMsg(message);
   }

   public static <T> ResultVO<T> error(String message) {
      return new ResultVO<T>().setCode(ResultEnums.ERROR).setMsg(message);
   }
   
}